﻿@{
    ViewBag.Title = "图书信息";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script>
    $(function () {
        $("[href='/BooksManage/BooksInfo']").parent("li").addClass("active").parent().parent("div").addClass("collapse in").parent("li").addClass("active");
    });
</script>
<div class="container-fluid">

    <div class="row">
        <div class="col-md-12">
            <div class="card">

                <div class="toolbar">
                    <!--        Here you can write extra buttons/actions for the toolbar              -->
                    <a href="/BooksManage/AddBookInfo">
                        <button class="btn btn-simple btn-wd">添加图书</button></a>
                </div>

                <table id="bootstrap-table" class="table">
                    <thead>
                        <th data-field="select">查看</th>
                        @*<th data-field="Pic" class="text-center">图片</th>*@
                        <th data-field="id" class="text-center">图书ID</th>
                        <th data-field="ISBN" class="text-center">ISBN</th>
                        <th data-field="name" class="text-center">图书名称</th>
                        <th data-field="TypeName" class="text-center">图书类型</th>
                        <th data-field="Author" class="text-center">作者</th>
                        <th data-field="Publishing" class="text-center">出版社</th>
                        <th data-field="PublicaDate" class="text-center">出版日期</th>
                        <th data-field="OriginalPrice" class="text-center">原价</th>
                        <th data-field="PresentPrice" class="text-center">现价</th>
                        <th data-field="actions" class="td-actions text-right" data-events="operateEvents"@* data-formatter="operateFormatter"*@>操作</th>
                    </thead>
                    <tbody>
                        @foreach (var item in ViewBag.BookInfoList)
                        {
                            <tr>
                                <td><a rel="tooltip" title="查看" class="btn btn-simple btn-info btn-icon table-action view" href="#" onclick="showSwal('@item.BookName','@item.Pic','@item.BookDesc')">
                                    <i class="fa pe-7s-search"></i>
                                </a></td>
                                @*<td class="text-center"><img src="~/Images/@item.Pic" style="width:40px;height:40px"/></td>*@
                                <td class="text-center">@item.BookID</td>
                                <td class="text-center">@item.BookNum</td>
                                <td class="text-center">@item.BookName</td>
                                <td class="text-center">@item.BookType.TypeName</td>
                                <td class="text-center">@item.Author</td>
                                <td class="text-center">@item.Pubishing</td>
                                <td class="text-center">@item.PublicaDate</td>
                                <td class="text-center">@item.OriginalPrice</td>
                                <td class="text-center">@item.PresentPrice</td>
                                <td class="text-right">
                                    <a rel="tooltip" title="上传图片" class="btn btn-simple btn-info btn-icon table-action" href="#" onclick="file('@item.BookID')">
                                        <i class="fa fa-image"></i>
                                    </a>
                                    <a rel="tooltip" title="编辑" class="btn btn-simple btn-warning btn-icon table-action edit" href="/BooksManage/EditBookInfo?id=@item.BookID">
                                        <i class="fa fa-edit"></i>
                                    </a>
                                    <a rel="tooltip" title="删除" class="btn btn-simple btn-danger btn-icon table-action remove" href="javascript:void(0)">
                                        <i class="fa fa-remove"></i>
                                    </a></td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <!--  end card  -->
        </div>
        <!-- end col-md-12 -->
    </div>
    <!-- end row -->
    <br />
</div>
<script>
    function file(id) {
        swal({
            title: "添加图片",
            html: "<br /><br /><form id='AddBookPic' action='/BooksManage/AddBookPic?id=" + id + "' method='post' enctype='multipart/form-data'><div style='margin-left:130px;'><input type='file' name='Pic'/></form></div>",
            //type: "warning",
            showCancelButton: true,
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false,
            closeOnCancel: false
        }, function (isConfirm) {
            if (isConfirm) {
                $("#AddBookPic").submit();
            } else {
                swal("取消", "", "error");
            }
        });
    }

    function showSwal(BookName, Pic, BookDesc) {
        swal({
            title: "图书简介",
            html:
 '<div style="margin-bottom:20px">' +
    '<div style="float: left;width:210px;height:190px;margin-right: 30px;margin-left: 20px;">' +
    '<img src="~/Images/' + Pic + '" style="width: 210px; height: 180px;"/>' +
    "</div>" +
    '<div style="float: left;width:200px;height:190px">' +
        "<p style='font-size:13px'>名称：" + BookName + "</p></br>" +
        "<p style='font-size:13px'>简介：" + BookDesc + "</p>" +
    "</div>" +
"</div><br/>"
        })
    }

</script>
